package com.voice.core.utils;

import java.io.Closeable;
import java.io.IOException;
import java.util.List;

public class CloseUtil {

    public static void close(Closeable... closeables) {
        try {
            if (closeables != null && closeables.length > 0) {
                for (Closeable closeable : closeables) {
                    closeable.close();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void close(List closeables) {
        if (closeables != null && closeables.size() > 0) {
            for (int i=0;i<closeables.size();i++) {
                Object object=closeables.get(i);
                if(object instanceof Closeable){
                    close((Closeable) object);
                }
            }
        }
    }
}
